package leecode

type Node589 struct {
	Val      int
	Children []*Node589
}

func preorder(root *Node589) (result []int) {
	var traversal func(node *Node589)
	traversal = func(node *Node589) {
		if node == nil {
			return
		}
		//中
		result = append(result, node.Val)
		for i := 0; i < len(node.Children); i++ {
			traversal(node.Children[i])
		}
	}
	traversal(root)
	return
}
